{include file="public/header" /}
</head>
<body>
<div class="x-body">
	<form action="{:url('recharge',['id'=>$info.id])}" class="layui-form layui-form-pane" id="form">
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="x-red">*</span>会员编号</label>
			<div class="layui-input-block">
				<input type="text" value="{$info.code}" readonly="readonly" lay-verify="required" class="layui-input"/>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="x-red">*</span>充值账户</label>
			<div class="layui-input-inline">
				<select name="type" lay-verify="required" lay-filter="type">
					<option value="">请选择</option>
					<!-- <option value="bonus">奖金</option> -->
					<option value="balance">余额</option>
					<!-- <option value="bonus1">欢笑豆</option> -->
					<!-- <option value="bonus2">欢乐豆</option> -->

				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><span class="x-red"></span>当前余额</label>
			<div class="layui-input-inline">
				<input type="text" id="balance" lay-verify="required" autocomplete="off" value="请选择" class="layui-input" readonly="readonly">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span class="x-red">*</span>类型</label>
			<div class="layui-input-block">
				<input type="radio" name="operation" value="1" lay-filter="radio" title="增加" checked/>
				<input type="radio" name="operation" value="2" lay-filter="radio" title="减少"/>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><span class="x-red">*</span>数量</label>
			<div class="layui-input-block">
				<input type="text" name="amount" lay-verify="required" class="layui-input" placeholder="请填写数量"/>
			</div>
		</div>
		<div class="layui-form-item" style="text-align: center;">
			<button class="layui-btn" lay-filter="save" lay-submit formObj="#form">充值</button>
		</div>
	</form>
</div>
</body>
<script>
	layui.use(['layer', 'form'], function(){
		var layer = layui.layer,form = layui.form;
		//原点 2020年5月22日17:11:42 监听select，获取余额
		form.on('select(type)', function (data) {
			data.value?get_balance(data.value):$("#balance").val('请选择');
		});
	});
	//原点 2020年5月22日17:12:09 获取余额
	function get_balance(value){
		$.ajax({
			type: 'GET',
			url: '{:url("recharge")}',
			data: {type:value,id:'{$info.id}'},
			dataType: "json",
			success: function (data) {
				if (data.code == 1) {
				
					$("#balance").val(data.result);
				} else {
					layer.alert(data.message);
				}
			}
		});
	}
</script>
</html>